import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


public class zzc4test {
    public static void main(String[] args) {
//        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//        numbers.stream().filter(n -> n%2==0).forEach(System.out::println);



//        List<String> words = Arrays.asList("Hello", "World", "Stream", "Java");
//        System.out.println(words.stream().collect(Collectors.joining(",")));


//        List<Student> students = Arrays.asList(
//                new Student("Alice", 85),
//                new Student("Bob", 78),
//                new Student("Charlie", 90)
//        );
//        System.out.println(students.stream().filter(n -> n.getAge() > 80).sorted((s1, s2) ->s2.getAge() - s1.getAge()).collect(Collectors.toList()));

//        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
//        numbers.stream().mapToInt(Integer::intValue).sum();


//        List<String> words = Arrays.asList("apple", "banana", "apple", "cherry");
//        List<String> collect = words.stream().map(String::toUpperCase).distinct().collect(Collectors.toList());

//        List<Integer> numbers = Arrays.asList(1, 2, 3, 11, 5);
//        numbers.stream().anyMatch(n ->n>10);


//        List<String> words = Arrays.asList("Hello", "World", "Stream", "Java");
//        words.stream().mapToInt(String::length).sum();


//        List<Order> orders = Arrays.asList(
//                new Order(100, "已完成"),
//                new Order(200, "未完成"),
//                new Order(150, "已完成")
//        );
//
//        System.out.println(orders.stream().filter(o -> o.getStatue() == "已完成").mapToInt(Order::getId).average());
//        List<Order> employees = Arrays.asList(
//                new Order("Alice", 30, "HR"),
//                new Order("Bob", 35, "IT"),
//                new Order("Charlie", 25, "HR")
//        );
//        employees.stream().collect(Collectors.groupingBy(Order::getStatue, Collectors.counting()));

        List<String> words = Arrays.asList("apple", "banana", "cherry", "kiwi");

        System.out.println(words.stream()
                .max((s1, s2) -> s1.length() - s2.length()).map(String::length).orElse(0));


    }
}
